package com.example.blog_system.service;

import com.example.blog_system.entity.UserInfo;
import com.example.blog_system.entity.vo.UserInfoVO;
import com.example.blog_system.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * Created with IntelliJ IDEA.
 * Description:用户服务层
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;


    public int add(UserInfo userInfo) {
        return userMapper.add(userInfo);
    }

    public UserInfo login(String username) {
        return userMapper.login(username);
    }

    public int updateLoginTime(LocalDateTime date, Integer id) {
        return userMapper.updateLoginTime(date, id);
    }
//    public UserInfo showUserInfo(String username) {
//        return userMapper.showUserInfo(username);
//    }


    //增加博文数量

    public int addBCount(Integer id) {
        return userMapper.addBCount(id);
    }

    // 减少博文数量
    public Integer delBCount(Integer id) {
        return userMapper.delBCount(id);
    }


    public UserInfoVO getAuthor(Integer id) {
        return userMapper.getAuthor(id);
    }



    public Integer addLike(Integer uid) {
        return userMapper.addLike(uid);
    }

    public String getUserByName(String username) {
        return userMapper.getUserByName(username);
    }

    public String getUsernameById(Integer uid) {
        return userMapper.getUsernameById(uid);
    }

    public Integer delAuthorLiked(Integer uid, Integer likedNum) {
        return userMapper.delAuthorLiked(uid, likedNum);
    }

    public String getEmail(String eMail) {
        return userMapper.getEmail(eMail);
    }

    public Integer modifyPassword(String name, String password) {
        return userMapper.modifyPassword(name, password);
    }

    public UserInfoVO getAuthorById(Integer id) {
        return userMapper.getAuthorById(id);
    }


    public Integer modifyProfile(Integer id, String profilePath) {
        return userMapper.modifyProfile(id, profilePath);
    }



    public Integer modifyMessage(String username, String newUsername, String newPassword) {
        return userMapper.modifyMessage(username, newUsername, newPassword);
    }

    public void log(String username, String desc) {
        userMapper.log(username, desc);
    }
}
